using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._MappingClusters
{
    /// <summary>
    /// <para>Spatially Constrained Multivariate Clustering</para>
    /// <para>Finds spatially contiguous clusters of features based on a set of feature attribute values and optional cluster size limits.</para>
    /// <para>根据一组要素属性值和可选的聚类大小限制查找空间上连续的要素聚类。</para>
    /// </summary>    
    [DisplayName("Spatially Constrained Multivariate Clustering")]
    public class SpatiallyConstrainedMultivariateClustering : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public SpatiallyConstrainedMultivariateClustering()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input Features</para>
        /// <para>The feature class or feature layer for which you want to create clusters.</para>
        /// <para>要为其创建聚类的要素类或要素图层。</para>
        /// </param>
        /// <param name="_output_features">
        /// <para>Output Features</para>
        /// <para>The new output feature class created containing all features, the analysis fields specified, and a field indicating to which cluster each feature belongs.</para>
        /// <para>创建的新输出要素类包含所有要素、指定的分析字段以及指示每个要素所属聚类的字段。</para>
        /// </param>
        /// <param name="_analysis_fields">
        /// <para>Analysis Fields</para>
        /// <para>A list of fields that will be used to distinguish one cluster from another.</para>
        /// <para>将用于区分一个集群与另一个集群的字段列表。</para>
        /// </param>
        public SpatiallyConstrainedMultivariateClustering(object _in_features, object _output_features, List<object> _analysis_fields)
        {
            this._in_features = _in_features;
            this._output_features = _output_features;
            this._analysis_fields = _analysis_fields;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Spatially Constrained Multivariate Clustering";

        public override string CallName => "stats.SpatiallyConstrainedMultivariateClustering";

        public override List<string> AcceptEnvironments => ["MResolution", "MTolerance", "XYResolution", "XYTolerance", "ZResolution", "ZTolerance", "geographicTransformations", "outputCoordinateSystem", "outputMFlag", "outputZFlag", "outputZValue", "parallelProcessingFactor", "qualifiedFieldNames", "randomGenerator", "scratchWorkspace", "workspace"];

        public override object[] ParameterInfo => [_in_features, _output_features, _analysis_fields, _size_constraints.GetGPValue(), _constraint_field, _min_constraint, _max_constraint, _number_of_clusters, _spatial_constraints.GetGPValue(), _weights_matrix_file, _number_of_permutations, _output_table];

        /// <summary>
        /// <para>Input Features</para>
        /// <para>The feature class or feature layer for which you want to create clusters.</para>
        /// <para>要为其创建聚类的要素类或要素图层。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Output Features</para>
        /// <para>The new output feature class created containing all features, the analysis fields specified, and a field indicating to which cluster each feature belongs.</para>
        /// <para>创建的新输出要素类包含所有要素、指定的分析字段以及指示每个要素所属聚类的字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _output_features { get; set; }


        /// <summary>
        /// <para>Analysis Fields</para>
        /// <para>A list of fields that will be used to distinguish one cluster from another.</para>
        /// <para>将用于区分一个集群与另一个集群的字段列表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Analysis Fields")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public List<object> _analysis_fields { get; set; }


        /// <summary>
        /// <para>Cluster Size Constraints</para>
        /// <para><xdoc>
        ///   <para>Specifies cluster size based on number of features per group or a target attribute value per group.</para>
        ///   <bulletList>
        ///     <bullet_item>None—No cluster size constraints will be used. This is the default.</bullet_item><para/>
        ///     <bullet_item>Number of features—A minimum and maximum number of features per group will be used.</bullet_item><para/>
        ///     <bullet_item>Attribute value—A minimum and maximum attribute value per group will be used.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>根据每个组的要素数或每个组的目标属性值指定聚类大小。</para>
        ///   <bulletList>
        ///     <bullet_item>无 - 不使用集群大小约束。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>要素数—将使用每个组的最小和最大要素数。</bullet_item><para/>
        ///     <bullet_item>属性值—将使用每个组的最小和最大属性值。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Cluster Size Constraints")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _size_constraints_value _size_constraints { get; set; } = _size_constraints_value._NONE;

        public enum _size_constraints_value
        {
            /// <summary>
            /// <para>None</para>
            /// <para>None—No cluster size constraints will be used. This is the default.</para>
            /// <para>无 - 不使用集群大小约束。这是默认设置。</para>
            /// </summary>
            [Description("None")]
            [GPEnumValue("NONE")]
            _NONE,

            /// <summary>
            /// <para>Number of features</para>
            /// <para>Number of features—A minimum and maximum number of features per group will be used.</para>
            /// <para>要素数—将使用每个组的最小和最大要素数。</para>
            /// </summary>
            [Description("Number of features")]
            [GPEnumValue("NUM_FEATURES")]
            _NUM_FEATURES,

            /// <summary>
            /// <para>Attribute value</para>
            /// <para>Attribute value—A minimum and maximum attribute value per group will be used.</para>
            /// <para>属性值—将使用每个组的最小和最大属性值。</para>
            /// </summary>
            [Description("Attribute value")]
            [GPEnumValue("ATTRIBUTE_VALUE")]
            _ATTRIBUTE_VALUE,

        }

        /// <summary>
        /// <para>Constraint Field</para>
        /// <para>The attribute value to be summed per cluster.</para>
        /// <para>每个聚类要求和的属性值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Constraint Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _constraint_field { get; set; } = null;


        /// <summary>
        /// <para>Minimum per Cluster</para>
        /// <para>The minimum number of features per cluster or the minimum attribute value per cluster. This must be a positive value.</para>
        /// <para>每个集群的最小要素数或每个集群的最小属性值。这必须是一个正值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Minimum per Cluster")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double? _min_constraint { get; set; } = null;


        /// <summary>
        /// <para>Fill to Limit</para>
        /// <para>The maximum number of features per cluster or the maximum attribute value per cluster. If a maximum constraint is set, the Number of Clusters parameter is inactive. This must be a positive value.</para>
        /// <para>每个集群的最大要素数或每个集群的最大属性值。如果设置了最大约束，则 Number of Clusters 参数处于非活动状态。这必须是一个正值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Fill to Limit")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double? _max_constraint { get; set; } = null;


        /// <summary>
        /// <para>Number of Clusters</para>
        /// <para><xdoc>
        ///   <para>The number of clusters to create. If this parameter is empty, the tool will evaluate the optimal number of clusters by computing a pseudo F-statistic value for clustering solutions with 2 through 30 clusters.</para>
        ///   <para>This parameter will be disabled if a maximum number of features or maximum attribute value has been set.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>要创建的集群数。如果此参数为空，则该工具将通过计算具有 2 到 30 个聚类的聚类解的伪 F 统计量值来评估最佳聚类数。</para>
        ///   <para>如果设置了最大要素数或最大属性值，则此参数将被禁用。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Clusters")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long? _number_of_clusters { get; set; } = null;


        /// <summary>
        /// <para>Spatial Constraints</para>
        /// <para><xdoc>
        ///   <para>Specifies how spatial relationships among features will be defined.</para>
        ///   <bulletList>
        ///     <bullet_item>Contiguity edges only—Clusters will contain contiguous polygon features. Only polygons that share an edge can be part of the same cluster.</bullet_item><para/>
        ///     <bullet_item>Contiguity edges corners— Clusters will contain contiguous polygon features. Only polygons that share an edge or a vertex can be part of the same cluster. This is the default for polygon features.</bullet_item><para/>
        ///     <bullet_item>Trimmed Delaunay triangulation— Features in the same cluster will have at least one natural neighbor in common with another feature in the cluster. Natural neighbor relationships are based on a trimmed Delaunay triangulation. Conceptually, Delaunay triangulation creates a nonoverlapping mesh of triangles from feature centroids. Each feature is a triangle node, and nodes that share edges are considered neighbors. These triangles are then clipped to a convex hull to ensure that features cannot be neighbors with any features outside the convex hull. This is the default for point features.</bullet_item><para/>
        ///     <bullet_item>Get spatial weights from file—Spatial, and optionally temporal, relationships are defined by a specified spatial weights file (.swm). Create the spatial weights matrix using the Generate Spatial Weights Matrix or Generate Network Spatial Weights tool. The path to the spatial weights file is specified by the Spatial Weights Matrix File parameter.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何定义要素之间的空间关系。</para>
        ///   <bulletList>
        ///     <bullet_item>仅限连续边—聚类将包含连续面要素。只有共享边的面才能成为同一聚类的一部分。</bullet_item><para/>
        ///     <bullet_item>连续性边角 - 聚类将包含连续面要素。只有共享边或顶点的面才能成为同一聚类的一部分。这是面要素的默认设置。</bullet_item><para/>
        ///     <bullet_item>修剪的 Delaunay 三角剖分 - 同一聚类中的要素将至少具有一个与聚类中另一个要素相同的自然邻居。自然邻域关系基于修剪后的 Delaunay 三角剖分。从概念上讲，Delaunay 三角剖分从特征质心创建非重叠的三角形网格。每个要素都是一个三角形节点，共享边的节点被视为相邻节点。然后将这些三角形剪裁到凸包上，以确保要素不能与凸包外部的任何要素相邻。这是点要素的默认设置。</bullet_item><para/>
        ///     <bullet_item>从文件中获取空间权重 - 空间关系和可选时间关系由指定的空间权重文件 （.swm） 定义。使用生成空间权重矩阵或生成网络空间权重工具创建空间权重矩阵。空间权重文件的路径由空间权重矩阵文件参数指定。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Spatial Constraints")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _spatial_constraints_value? _spatial_constraints { get; set; } = null;

        public enum _spatial_constraints_value
        {
            /// <summary>
            /// <para>Contiguity edges only</para>
            /// <para>Contiguity edges only—Clusters will contain contiguous polygon features. Only polygons that share an edge can be part of the same cluster.</para>
            /// <para>仅限连续边—聚类将包含连续面要素。只有共享边的面才能成为同一聚类的一部分。</para>
            /// </summary>
            [Description("Contiguity edges only")]
            [GPEnumValue("CONTIGUITY_EDGES_ONLY")]
            _CONTIGUITY_EDGES_ONLY,

            /// <summary>
            /// <para>Contiguity edges corners</para>
            /// <para>Contiguity edges corners— Clusters will contain contiguous polygon features. Only polygons that share an edge or a vertex can be part of the same cluster. This is the default for polygon features.</para>
            /// <para>连续性边角 - 聚类将包含连续面要素。只有共享边或顶点的面才能成为同一聚类的一部分。这是面要素的默认设置。</para>
            /// </summary>
            [Description("Contiguity edges corners")]
            [GPEnumValue("CONTIGUITY_EDGES_CORNERS")]
            _CONTIGUITY_EDGES_CORNERS,

            /// <summary>
            /// <para>Trimmed Delaunay triangulation</para>
            /// <para>Trimmed Delaunay triangulation— Features in the same cluster will have at least one natural neighbor in common with another feature in the cluster. Natural neighbor relationships are based on a trimmed Delaunay triangulation. Conceptually, Delaunay triangulation creates a nonoverlapping mesh of triangles from feature centroids. Each feature is a triangle node, and nodes that share edges are considered neighbors. These triangles are then clipped to a convex hull to ensure that features cannot be neighbors with any features outside the convex hull. This is the default for point features.</para>
            /// <para>修剪的 Delaunay 三角剖分 - 同一聚类中的要素将至少具有一个与聚类中另一个要素相同的自然邻居。自然邻域关系基于修剪后的 Delaunay 三角剖分。从概念上讲，Delaunay 三角剖分从特征质心创建非重叠的三角形网格。每个要素都是一个三角形节点，共享边的节点被视为相邻节点。然后将这些三角形剪裁到凸包上，以确保要素不能与凸包外部的任何要素相邻。这是点要素的默认设置。</para>
            /// </summary>
            [Description("Trimmed Delaunay triangulation")]
            [GPEnumValue("TRIMMED_DELAUNAY_TRIANGULATION")]
            _TRIMMED_DELAUNAY_TRIANGULATION,

            /// <summary>
            /// <para>Get spatial weights from file</para>
            /// <para>Get spatial weights from file—Spatial, and optionally temporal, relationships are defined by a specified spatial weights file (.swm). Create the spatial weights matrix using the Generate Spatial Weights Matrix or Generate Network Spatial Weights tool. The path to the spatial weights file is specified by the Spatial Weights Matrix File parameter.</para>
            /// <para>从文件中获取空间权重 - 空间关系和可选时间关系由指定的空间权重文件 （.swm） 定义。使用生成空间权重矩阵或生成网络空间权重工具创建空间权重矩阵。空间权重文件的路径由空间权重矩阵文件参数指定。</para>
            /// </summary>
            [Description("Get spatial weights from file")]
            [GPEnumValue("GET_SPATIAL_WEIGHTS_FROM_FILE")]
            _GET_SPATIAL_WEIGHTS_FROM_FILE,

        }

        /// <summary>
        /// <para>Spatial Weights Matrix File</para>
        /// <para>The path to a file containing spatial weights that define spatial, and potentially temporal, relationships among features.</para>
        /// <para>包含空间权重的文件的路径，用于定义要素之间的空间关系和潜在的时间关系。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Spatial Weights Matrix File")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _weights_matrix_file { get; set; } = null;


        /// <summary>
        /// <para>Permutations to Calculate Membership Probabilities</para>
        /// <para><xdoc>
        ///   <para>The number of random permutations for the calculation of membership stability scores. If 0 (zero) is chosen, probabilities will not be calculated. Calculating these probabilities uses permutations of random spanning trees and evidence accumulation.</para>
        ///   <para>This calculation can take a significant time to run for larger datasets. It is recommended that you iterate and find the optimal number of clusters for your analysis first; then calculate probabilities for your analysis in a subsequent run. Setting the Parallel Processing Factor Environment setting to 50 may improve the run time of the tool.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>用于计算成员稳定性分数的随机排列数。如果选择 0（零），则不会计算概率。计算这些概率使用随机生成树的排列和证据积累。</para>
        ///   <para>对于较大的数据集，此计算可能需要花费大量时间。建议您先进行迭代并找到用于分析的最佳聚类数;然后计算后续运行中分析的概率。将“并行处理因子环境”设置设置为 50 可能会缩短工具的运行时间。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Permutations to Calculate Membership Probabilities")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_permutations { get; set; } = 0;


        /// <summary>
        /// <para>Output Table for Evaluating Number of Clusters</para>
        /// <para>The table created containing the results of the F-statistic values calculated to evaluate the optimal number of clusters. The chart created from this table can be accessed in the Contents pane under the output feature layer.</para>
        /// <para>创建的表包含计算的 F 统计量值的结果，用于评估最佳聚类数。根据此表创建的图表可在输出要素图层下的内容窗格中进行访问。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Table for Evaluating Number of Clusters")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_table { get; set; } = null;


        public SpatiallyConstrainedMultivariateClustering SetEnv(object MResolution = null, object MTolerance = null, object XYResolution = null, object XYTolerance = null, object ZResolution = null, object ZTolerance = null, object geographicTransformations = null, object outputCoordinateSystem = null, object outputMFlag = null, object outputZFlag = null, object outputZValue = null, object parallelProcessingFactor = null, bool? qualifiedFieldNames = null, object randomGenerator = null, object scratchWorkspace = null, object workspace = null)
        {
            base.SetEnv(MResolution: MResolution, MTolerance: MTolerance, XYResolution: XYResolution, XYTolerance: XYTolerance, ZResolution: ZResolution, ZTolerance: ZTolerance, geographicTransformations: geographicTransformations, outputCoordinateSystem: outputCoordinateSystem, outputMFlag: outputMFlag, outputZFlag: outputZFlag, outputZValue: outputZValue, parallelProcessingFactor: parallelProcessingFactor, qualifiedFieldNames: qualifiedFieldNames, randomGenerator: randomGenerator, scratchWorkspace: scratchWorkspace, workspace: workspace);
            return this;
        }

    }

}